import java.io.*;
import java.text.*;
import java.util.*;


public class Charge {
    private String A, B;

    Charge(String A, String B) {
        this.A = A;
        this.B = B;
    }

    public double money = 0;

    public String ChargeMoney() throws ParseException {
        String time1 = A;
        String time2 = B;


        SimpleDateFormat format1 = new SimpleDateFormat("yyyyMMddHHmmss");
        Date date1 = format1.parse(time1);
        Date date2 = format1.parse(time2);
        Calendar cal1 = Calendar.getInstance();
        cal1.setTime(date1);
        Calendar cal2 = Calendar.getInstance();
        cal2.setTime(date2);
        long phonetime = cal2.getTime().getTime() - cal1.getTime().getTime();
        long minute;

        if (phonetime >= 0 && phonetime / 1000 < 60 || phonetime % 60000 > 0) //不到一分钟按一分钟计算
            minute = phonetime / 1000 / 60 + 1;
        else
            minute = phonetime / 1000 / 60;

        if (cal1.get(Calendar.MONTH) == Calendar.OCTOBER && cal1.get(Calendar.DATE) >= 25 && cal1.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY) {
            if (cal1.get(Calendar.HOUR_OF_DAY) == 2 && cal2.get(Calendar.HOUR_OF_DAY) == 2 && cal2.get(Calendar.HOUR_OF_DAY) < 3 && cal2.get(Calendar.MINUTE) <= cal1.get(Calendar.MINUTE)) {
                minute += 60;

            } else if (cal1.get(Calendar.HOUR_OF_DAY) < 2 && cal2.get(Calendar.HOUR_OF_DAY) >= 2) {

            } else {

            }

        } else {
            if (cal2.get(Calendar.MONTH) == Calendar.OCTOBER && cal2.get(Calendar.DATE) >= 25 && cal2.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY) {
                if (cal2.get(Calendar.HOUR_OF_DAY) >= 2)
                    minute += 60;
            } else {
                if ((cal1.get(Calendar.MONTH) == Calendar.MARCH && cal1.get(Calendar.DATE) >= 25 && cal1.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY)) {
                    if (cal1.get(Calendar.HOUR_OF_DAY) < 2 && cal2.get(Calendar.HOUR_OF_DAY) >= 3)
                        minute -= 60;
                } else {
                    if ((cal2.get(Calendar.MONTH) == Calendar.MARCH && cal2.get(Calendar.DATE) >= 25 && cal2.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY)) {
                        //但是结束时间在（从前一天打到这一天
                        if (cal2.get(Calendar.HOUR_OF_DAY) >= 3)
                            minute -= 60;
                    }
                }
            }

        }
        if (minute > 1800 || minute <= 0) {
            return "通话时间输入错误，请重新输入。";
        } else {
            if (minute <= 20)
                money = minute * 0.05;
            else
                money = 1 + (minute - 20) * 0.1;
        }
        DecimalFormat format2=new DecimalFormat("#0.00");
        String s1 = format2.format(money);
        return s1;
}
}

